<?php
include 'api.php';
include 'wow.html';
/*

try {
	$character = $api->getCharacterApi()->getCharacter($realm, $char,
		array('guild', 'stats', 'items', 'titles', 'professions', 'talents','reputation', 'achievements'));

mounts, progression, pvp, quests??

	echo $character['name'];
} catch (NotFoundException $e) {
	echo 'That character does not exist!';
} catch(\Exception $e) {
	echo 'There was an error fetching the character from the armory';
}

*/

//Achievement APIs
# Fetch character achievement definitions
//$data = $api->getAchievementsApi()->getCharacterAchievements();
# Fetch guild achievement definitions
//$data = $api->getAchievementsApi()->getGuildAchievements();

//Arena APIs
# Fetch arena info
//Call to undefined method WowApi\Api\Arena::getArena() i
//$arena = $api->getArenaApi()->getArena('TEAMNAME', 'REALMNAME', 'TEAMSIZE');
# Fetch all fields
//$arena = $api->getArenaApi()->getArena('TEAMNAME', 'REALMNAME', 'TEAMSIZE', TRUE);
# Fetch arena ladder
//$arena = $api->getArenaApi()->getArenaLadder('ruin', '3');
# Fetch a certain number of teams on the ladder
//$arena = $api->getArenaApi()->getArenaLadder('BATTLEGROUP', 'TEAMSIZE', NUMBEROFTEAMS);

//Auction APIs
# Fetch the auctions dump file, after checking the index for a new version
//$data = $api->getAuctionApi()->getAuctions('REALMNAME');
# Check the index for a new arena dump
//$data = $api->getAuctionApi()->getAuctionIndex('REALMNAME');
# Fetch the auctions dump file
//$data = $api->getAuctionApi->getAuctionDump('URL');

//Character APIs
# Fetch character info
//$data = $api->getCharacterApi()->getCharacter('REALMNAME', 'CHARACTERNAME');
# Fetch optional fields
//$data = $api->getCharacterApi()->getCharacter('REALMNAME', 'CHARACTERNAME', array('guild', 'stats'));

//Classes APIs
# Fetch array containing the classes
//$data = $api->getClassesApi()->getClasses();

//Guild APIs
# Fetch guild info
//$data = $api->getGuildApi()->getGuild('REALMNAME', 'GUILDNAME');
# Fetch optional fields
//$data = $api->getGuildApi()->getGuild('REALMNAME', 'GUILDNAME', array('members'));
# Fetch all fields
//$data = $api->getGuildApi()->getGuild('REALMNAME', 'GUILDNAME', true);
//Guild Perks APIs
# Fetch array containing the guild perks
//$data = $api->getGuildPerksApi()->getPerks();
//Guild Rewards APIs
# Fetch array containing the rewards
//$data = $api->getGuildRewardsApi()->getRewards();

//Item Classes APIs
# Fetch array containing the item classes
//$data = $api->getItemClassesApi()->getItemClasses();
//Item APIs
# Fetch array containing the item data
//$data = $api->getItemsApi()->getItem('ITEMID');

//Quest APIs
# Fetch array containing the quest data
//$data = $api->getQuestsApi()->getQuest('QUESTID');

//Races APIs
# Fetch array containing the races
//$data = $api->getRacesApi()->getItem('getRaces');

//Realm APIs
//Note: When fetching realms with spaces in the name, use the realm slug.
# Fetch multiple realms
//$data = $api->getRealmApi()->getRealms(array('REALM1', 'REALM2'));
# Fetch a single realms status
//$data = $api->getRealmApi()->getRealm('REALMNAME');
# Fetch all offline realms
//$data = $api->getRealmApi()->filterByStatus(Realm::STATUS_DOWN);

if (!isset($_POST['submitted']))

{
	echo "<form method=post>";
	echo "<p>";
	echo "Character/Guild: <input type='text' name='char'/><br/><br/>";
	echo "Realm/other data: <input type='text' name='realm'/><br/><br/>";
	echo "Search type: <select name='search'>";
	echo "<option value='charAll'>Character-All</option>";
	echo "<option value='charGuild'>Character-Guild</option>";
	echo "<option value='charStats'>Character-Stats</option>";
	echo "<option value='charItems'>Character-Items</option>";
	echo "<option value='charTitles'>Character-Titles</option>";
	echo "<option value='charProfs'>Character-Professions</option>";
	echo "<option value='charTalents'>Character-Talents</option>";
	echo "<option value='charAch'>Character-Achievement</option>";
	echo "<option value='charAch'>Character-reputation</option>";
	echo "<option value='ach'>Achievements</option>";
	echo "<option value='guildInfo'>Guild-Info</option>";
	echo "<option value='guildAll'>Guild-All info</option>";
	echo "<option value='guildAch'>Guild-Achievement</option>";//here
	echo "<option value='guildPerks'>Guild-Perks</option>";
	echo "<option value='guildRewards'>Guild-Rewards</option>";
	echo "<option value='quest'>Quest</option>";
	echo "<option value='item'>Item</option>";
	echo "<option value='recipe'>Recipe/Spell</option>";	
	echo "<option value='arena'>Arena info</option>";
	echo "<option value='arenaLadder'>Arena ladder</option>";
	echo "<option value='auctions'>Auctions</option>";
	echo "<option value='auctionsIndex'>Auctions index</option>";
	echo "<option value='classes'>Classes</option>";
	echo "<option value='iClasses'>Item Classes</option>";
	echo "<option value='races'>Races</option>";
	echo "</select><br/><br/>";
	echo "<input type='submit' value='search'/>";
	echo "<input type='hidden' name='submitted' value='1'/>";
	echo "</p>";
	echo "</form>";
}
else
{
	try{
		$search = $_POST['search'];
		$text = $_POST['char'];
		$realm = $_POST['realm'];

		if ($search=='charAll')
		{
			$data = $api->getCharacterApi()->getCharacter($realm,$text, array('guild', 'stats', 'items', 'titles', 'professions', 'talents'));
		}
		else if ($search=='charGuild')
			{
				$data = $api->getCharacterApi()->getCharacter($realm,$text, array('guild'));
			}
		else if ($search=='charStats')
			{
				$data = $api->getCharacterApi()->getCharacter($realm,$text, array('stats'));
			}
		else if ($search=='charItems')
			{
				$data = $api->getCharacterApi()->getCharacter($realm,$text, array('items'));
			}
		else if ($search=='charTitles')
			{
				$data = $api->getCharacterApi()->getCharacter($realm,$text, array('titles'));
			}
		else if ($search=='charProfs')
			{
				$data = $api->getCharacterApi()->getCharacter($realm,$text, array('professions'));
			}
		else if ($search=='charTalents')
			{
				$data = $api->getCharacterApi()->getCharacter($realm,$text, array('talents'));
			}
		else if ($search=='charAch')
			{
				$data = $api->getCharacterApi()->getCharacter($realm,$text, array('achievements'));
			}
		else if ($search=='charRep')
			{
				$data = $api->getCharacterApi()->getCharacter($realm,$text, array('reputation'));
			}
		else if ($search=='ach')
			{
				$data = $api->getAchievementsApi()->getCharacterAchievements();
			}			
		else if ($search=='guildInfo')
			{
				$data = $api->getGuildApi()->getGuild($realm,$text);
			}
		else if ($search=='guildAll')
			{
				$data = $api->getGuildApi()->getGuild($realm, $text, true);
			}									
		else if ($search=='guildAch')
			{
				$data = $api->getAchievementsApi()->getGuildAchievements();
			}
		else if ($search=='recipe')
			{
				$data = $api->getRecipeApi()->getRecipe(33994);
			}	
			
			
/*
	echo "<option value='guildAll'>Guild-All info</option>";
	echo "<option value='guildAch'>Guild-Achievement</option>";
	echo "<option value='guildPerks'>Guild-Perks</option>";
	echo "<option value='guildRewards'>Guild-Rewards</option>";
	echo "<option value='quest'>Quest</option>";
	echo "<option value='item'>Item</option>";
	echo "<option value='arena'>Arena info</option>";
	echo "<option value='arenaLadder'>Arena ladder</option>";
	echo "<option value='auctions'>Auctions</option>";
	echo "<option value='auctionsIndex'>Auctions index</option>";
	echo "<option value='classes'>Classes</option>";
	echo "<option value='iClasses'>Item Classes</option>";
	echo "<option value='races'>Races</option>";
	
( [id] => 1194 [title] => Into the Nether [points] => 10 [description] => Complete 120 quests in Netherstorm. )	
	338 - 1194
	338 - 1
	338 - 1324402721000 timestamp
	338 - 1324402721000 created
	
	1194-5382
	
[868] => 28992415 868 is justly rewarded = 28992415 is current quantity
5752 is the id for this achievement
1266612688000 created
	


	
*/


		else
		{
			echo "No data available<br/><br/>";
		}
	}
	catch (exception $e)
	{
		echo 'Error retrieving realm data: ', $e->getMessage();
		
		
	}

	echo "<p class='footnote'>" . print_r($data) . "</p>";
	echo "<br/><br/><a class='reg' href='example.php'>Roll again<a/>";
}



?>